package org.urchr.beorganized.dao.tables;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="sessions")
public class Session implements Serializable {

	private static final long serialVersionUID = 3859138073357061731L;
	private int id;
	private String code;
	private Date valid;
	private String ip;
	private User user;
	
	public void setId(int id) {
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	@Column
	public String getCode() {
		return code;
	}
	
	public void setValid(Date valid) {
		this.valid = valid;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getValid() {
		return valid;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@Column
	public String getIp() {
		return ip;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne
	@JoinColumn(name="id_user")
	public User getUser() {
		return user;
	}
}
